﻿using System;
using System.Collections.Generic;
using ArtClub.DAL;
using ArtClub.Model;

namespace ArtClub.Controller
{
    public class ArtCtr : IArtCtr
    {
        private ArtDB artDb;
        public ArtCtr()
        {
            artDb = new ArtDB();
        }
        public List<Art> ListArts()
        {
            
            return artDb.ListArt();
        }

        public Art GetArt(int id)
        {
         
            var art = artDb.GetArt(id);
            if (art == null)
            {
                throw new ArgumentNullException("The requested Art item was not found.");
            }
            return art;
        }

        public List<Art> ListArtByName(string name)
        {
            
            return artDb.ListArtByName(name);
        }

		public void Create(Art art)
		{
            ValidateArt(art);
			artDb.Create(art);
		}

        private void ValidateArt(Art art)
        {
            if(string.IsNullOrEmpty(art.Name))
                throw new Exception("Name is not correct");
            if(string.IsNullOrEmpty(art.Description))
                throw new Exception("There is nothing in the description");

        }

		public void Update(Art art)
		{
			throw new NotImplementedException();
		}

		public void Delete(int id)
		{
			throw new NotImplementedException();
		}
	}
}
